package com.example.personnel_oa.controller;
//Controler负责请求转发，接受页面过来的参数，传给Service处理，接到返回值，再传给页面。
import com.example.comment_oa.pojos.Contract;
import com.example.comment_oa.response.AjaxResponse;
import com.example.personnel_oa.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController
//控制器类
@CrossOrigin
//禁止Ajax访问当前站点外的资源
@Controller
//控制器
@RequestMapping("/personnelOa")
//跨域处理请求
public class ContractController {
    @Autowired
 //注入
    ContractService contractService;

    //查询全部合同数据
    @GetMapping("/Contract/alldim")
    //用于处理请求方法的GET类型
    public AjaxResponse Methods_con(){
        return AjaxResponse.success(contractService.Methods_con());
    }

    // 员工入职后添加到合同表中，未签署试用合同
    @PostMapping("Contract/addContract")
    //用于处理请求方法的POST*类型
    public AjaxResponse addContract(@RequestBody Contract contract){
        int i = contractService.addContract(contract);
        return AjaxResponse.success(i);
    }
    //根据id查询合同数据
    @GetMapping("Contract/conId/{conId}")
    //用于处理请求方法的GET类型
    public AjaxResponse conId(@PathVariable("conId")int conId){
        Contract contract = contractService.conId(conId);
        return AjaxResponse.success(contract);
    }
    //签试用合同
    @PostMapping("Contract/shiyong")
    //用于处理请求方法的POST*类型
    public AjaxResponse shiyong(@RequestBody Contract contract){
        int shiyong = contractService.shiyong(contract);
        return AjaxResponse.success(shiyong);
    }
    //签正式合同
    @PostMapping("Contract/zhengshi")
    //用于处理请求方法的POST*类型
    public AjaxResponse zhengshi(@RequestBody Contract contract){
        int shiyong = contractService.zhengshi(contract);
        return AjaxResponse.success(shiyong);
    }
    //签解除合同
    @PostMapping("Contract/jiechu")
    //用于处理请求方法的POST*类型
    public AjaxResponse jiechu(@RequestBody Contract contract){
        int shiyong = contractService.jiechu(contract);
        return AjaxResponse.success(shiyong);
    }

}
